package com.xbongbong.saas.model;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.aiassistant.domain.entity.AiSupplierEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.saas.domain.entity.ext.SupplierEntityExt;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;
/**
 * 供应商
 * @author Jian.Wang
 * @date 2019/1/29 20:38
 * @since v1.0
 * @version v1.0
 */
public interface SupplierModel extends IModel<SupplierEntityExt> {
    /**
     * 供应商数据插入
     * @param entity 供应商实体
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @throws XbbException 异常
     * @return Integer
     */
    @Override
    Integer insert(SupplierEntityExt entity) throws XbbException;
    /**
     * 供应商数据更新
     * @param entity 供应商实体
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @throws XbbException 异常
     * @return Integer
     */
    @Override
    Integer update(SupplierEntityExt entity) throws XbbException;
    /**
     * 供应商数据查询多个
     * @param param 参数
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @return List<SupplierEntityExt>
     */
    @Override
    List<SupplierEntityExt> findEntitys(Map<String, Object> param);
    /**
     * 供应商数据查询条数
     * @param param 参数
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @return Integer
     */
    @Override
    Integer getEntitysCount(Map<String, Object> param);

    /**
     * 供应商数据单条查询
     * @param key 主键ID
     * @param corpid 公司ID
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @return Integer
     */
    SupplierEntityExt getByKey(Long key, String corpid);

    /**
     * 批量删除供应商
     * @param supplierIdIn 供应商id列表
     * @param corpid 公司id
     * @return
     * @throws XbbException
     */
    Integer deleteBatch(List<Long> supplierIdIn, String corpid) throws XbbException;


    /**
     * 单个删除
     * @param id
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer deleteByKey(Long id,String corpid) throws XbbException;

    /**
     * 批量更新
     * @param updateList 供应商id列表
     * @param corpid 公司id
     * @return
     * @throws XbbException
     */
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid) throws XbbException;

    /**
     * 获取智能助手需要的供应商数据
     *
     * @param corpid 公司id
     * @param idIn 数据ids
     * @return
     * @throws
     * @author hongxiao
     * @date: 2020-02-24 16:55
     * @since v4.13.0
     * @version v4.13.0
     */
    List<AiSupplierEntity> getSupplierList4Ai(String corpid, List<Long> idIn);

    /**
     * 在供应商名称是唯一的情况下，可以使用名称来查询
     * @param corpid
     * @param supplierName
     * @return
     * @throws XbbException
     */
    SupplierEntityExt getBySupplierName(String corpid, String supplierName) throws XbbException;

    /**
     * 批量更新
     * @param updateList
     * @param corpid
     * @param refreshPolicy
     * @return
     */
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    List findEntitysWithoutSub(Map<String, Object> param);

    /**
     * 编辑时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     * @author Jian.Wang
     * @date 2019-02-25 21:23
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;
    /**
     * 新建时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     * @author long.rao
     * @date 2019-02-13 20:53
     */
    void formatAddExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 供应商编辑格式化数据格式
     *
     * @param saasAnalysisDataDTO saas编辑数据
     * @throws XbbException 参数格式错误异常
     * @param result 要返回的jsonobject
     * @author Jian.Wang
     * @date 2019/1/23 20:00
     * @since v1.0
     * @throws XbbException 异常
     **/
    void formatData(SaasAnalysisDataDTO saasAnalysisDataDTO, JSONObject result) throws XbbException;

    Integer updateTime(Long id,String corpid) throws XbbException ;
}
